package com.taichuan.selfcheck.utils;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * 用于管理 存储测试结果的文件 SharedPreferences
 */
public class ResultRecordManager {

    private static ResultRecordManager mInstance = null;

    /**
     * 获取ResultRecordManager的实例
     *
     * @return
     */
    public static ResultRecordManager getInstance() {
        if (mInstance == null) {
            synchronized (ResultRecordManager.class) {
                if (mInstance == null) {
                    mInstance = new ResultRecordManager();
                }
            }
        }
        return mInstance;
    }

    /**
     * 存储测试结果的文件名
     */
    private static final String TC_SELF_CHECK_RESULT_FILE_NAME = "TC_SELF_CHECK_RESULT_FILE_NAME";
    /**
     * 存储测试结果的文件
     */
    private SharedPreferences testResultSP;

    /**
     * 初始化
     * @param context
     */
    public void InitSP(Context context){
        testResultSP = context.getSharedPreferences(TC_SELF_CHECK_RESULT_FILE_NAME, Context.MODE_PRIVATE);
    }

    public SharedPreferences getResultSp(Context context){
        return testResultSP;
    }
}
